package dev.projectnightfall.graphics;

import dev.projectnightfall.graphics.states.*;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.StateBasedGame;

/**
 * Main render engine. The game is state based. The current planned states are :
 * 1) Main Menu 
 * 2) Option screen 
 * 3) Gameplay state Those are the main states.
 */
public class RenderEngine extends StateBasedGame {

    AppGameContainer game;
    /**
     * Game States Definitions : It simply gives each state a (non-changeable)
     * ID.
	 *
     */
    public static final int MAINMENUSTATE = 1;
    public static final int OPTIONSMENUSTATE = 2;
    public static final int GAMEPLAYSTATE = 4;
    public static final int PAUSESTATE = 8;
    /**
     * Definition of the spritesheet Sprites size : 16x16 Color depth : 32bits
     * Sprite sheet size : 800x800 Rows : 50 Columns : 50 Maximum possible
     * sprites : 2500
         *
     */
    public static final int SPRITE_SIZE = 16;
    public static int SCREEN_WIDTH = 800;
    public static int SCREEN_HEIGHT = 600;
    public static final int ROWS = (int) SCREEN_HEIGHT / SPRITE_SIZE;
    public static final int COLS = (int) SCREEN_WIDTH / SPRITE_SIZE;

    /**
     * Main constructor of the render engine.
     *
     * @throws SlickException Whenever Slick crashes, it throws this exception.
     */
    public RenderEngine() throws SlickException {
        super("Project NightFall");

        game = new AppGameContainer(this);
        game.setDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, false);
        game.start();
    }

    /**
     * This method is called to initialize the internal list of available
     * GameStates.
     */
    @Override
    public void initStatesList(GameContainer container) throws SlickException {
        this.addState(new MainMenuState(MAINMENUSTATE));
        this.addState(new OptionsMenuState(OPTIONSMENUSTATE));
        this.addState(new GameplayState(GAMEPLAYSTATE));
        this.addState(new PauseState(PAUSESTATE));
    }
}
